package net.sxnic.workflow.transition;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import net.sxinfo.core.entity.AbstractEntity;
import net.sxnic.workflow.node.Node;
import net.sxnic.workflow.pd.Pd;

@Entity
@Table(name = "wf_transition")
@BatchSize(size = 10)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Transition extends AbstractEntity{
	
	private static final long serialVersionUID = -812315893956860127L;

	private int xorder;
	
	@Column(length=30)
	private String name;	
	
	@ManyToOne(fetch = FetchType.LAZY)
	@Cascade(value = { CascadeType.REFRESH})
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private Node from;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@Cascade(value = { CascadeType.REFRESH})
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private Node to;
	
	@ManyToOne
	@Cascade(value = { CascadeType.REFRESH})
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)	
	private Pd pd;	

	public Transition() {
		super();
	}

	public Transition(String name) {
		super();
		this.name = name;
	}

	public int getXorder() {
		return xorder;
	}

	public void setXorder(int xorder) {
		this.xorder = xorder;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Node getTo() {
		return to;
	}

	public void setTo(Node to) {
		this.to = to;
	}

	public Node getFrom() {
		return from;
	}

	public void setFrom(Node from) {
		this.from = from;
	}

	public Pd getPd() {
		return pd;
	}

	public void setPd(Pd pd) {
		this.pd = pd;
	}
}
